home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 7
/
Apprentice-Release7.iso
/
Environments
/
MacMETH 3.2.4
/
MEdit ƒ
/
Macros ƒ
/
Macros.MCR
< prev
Wrap
Text File
|
1996-06-20
|
31KB
|
996 lines
**********************************************************************************
* This macro file is useful for Modula-2 programming. It allows you to
* insert all important program-structures with one key.
* derived from Pascal.Mcr of Matthias Aebi 31.03.86
* written : 16.10.86 Alex Itten
* Last modification : 20.10.86 Alex Itten
* 18.08.87 Andreas Fischlin
* 31.08.87 Andreas Fischlin to MEdit V1.54 adapted
* 11.02.88 A. Fischlin, Wrap and rearrange comment
* macro (22,36) added
* 11.09.88 Olivier Roth, adapted to pers. use
* 24.10.88 Olivier Roth, some bug fixes
* 30.01.89 Andreas Fischlin, adapted to pers. use
* and update to 1989 version made
* 13.02.89 Andreas Fischlin some minor changes in
* macro procedure (without VAR), and
* small format fixes in macro 5, 35, 44
* MacPlus version separated from Mac IIx
* version and making a generic version
* (see list of markers below)
* 14.02.89 Correction for Mac Plus
* 27.02.89 Thomas Nemecek, adapted to pers. use
* 10.06.89 Olivier Roth, menu layout & some short
* cuts (cmd-W is Close, Wrap->A).
* 23.08.89 A. Fischlin adapted to new versions of
* MacMETH, DM, and ModelWorks
* Case now Option^S instead of Option^A
* so that wrap in both versions may use
* Command^A resp. Option^A
* 25.10.89 O.R. removal of CONST, TYPE, VAR.
* Goto M2-Error added.
* 25.10.89 A.F. all versions corrected, new import
* list for ModelWorks 1.3 inserted
* 30.04.90 A.F. all versions corrected for DM 2.0,
* MacMETH 2.6+ and ModelWorks 2.0
* 15.09.90 A.F. versions corrected for DM 2.01 and
* ModelWorks 2.01
* 20.09.90 O.R.: version for MacMETH error support,
* complete revision.
* 01.10.90 O.R.: version 1.6 (with new MComp version)
* 26.10.90 O.R.: version 1.62 (with new MComp & MEdit)
* 09.11.90 O.R.: version 1.64 (with new MComp & MEdit)
* 24.11.90 O.R.: version 1.65 for students & ETH faculty
* 11.01.91 O.R.: version 1.66 for students & ETH faculty
* 12.06.91 A.F.: version 1.70 using no longer absolute
* path to MacMETH but now relative path to
* RAMSES shell
* 24.06.91 A.F.: Bug fix in macro «Find M2-Error» where
* WName result was returned inconsistently. Now
* using $1 as intermediate storage variable.
* 01.07.91 O.R.: version 1.71 for students & ETH faculty
* 12.07.91 O.R.: version 1.72 for students & ETH faculty
* 13.08.91 O.R.: version 1.73 for students & ETH faculty
* 20.11.91 A.F.: Minor version corrections and updates
* for RAMSES shell 1.02b4, MacMETH 3.0, DM 2.031,
* and ModelWorks 2.031.
* 13.01.92 D.G.: Updates for RAMSES Shell 1.2,
* MacMETH 3.0, DM 2.2 and ModelWorks 2.2.
* 10/03/92 D.G.: Updates for RAMSES Shell 1.2b0, MacMETH 3.2
* 31/08/92 A.F.: Version 1.79
* 29/09/92 jth final release for MacMETH 3.2.
* 02/10/92 - J. Thoeny as user of this generic version added
* Reconstruction of a generic version from
* - J. Thoeny's new XX version
* - Avoiding any non ASCII characters to allow
* for easier port of code to MS-DOS PC and Unix
* machines
* 22/10/92 A.F.: Support for MiniRAMSESShell added, i.e.
* mini* markers added
* 24/10/92 Launch shell sends now a comp message ('DMEv',231,0,0)
* 08/11/92 For RAMSES Mini shell support Cmd^0 must not
* send a 'MnCh' high level event.
* 13/11/92 Support for new MEdit version 1.8
* 02/12/92 Added Launch Shell and Simulate Macro
* 05/12/92 A.F.: Adapted for RAMSES 2.0
* 29/04/93 jth support for warning 263
* 07/06/93 A.F.: Adapted for RAMSES 2.2
* 29/04/93 jth MacMETH 3.2.2
* 12/09/95 af MacMETH 3.2.3
* 14/05/96 af removal of versions in names for more generic
* macros
*
**********************************************************************************
* Versions:
* M2-Generic(1.80).MCR
* MComp 1.40
* MEdit 1.80
**********************************************************************************
* Legend:
* Δ - Shift
* xNum - key x on numeric key pad
* Opt - Option (alt) key
* ^ - between two keys means press simultaneously
* CursLeft - Cursor Left
* CursRight - Cursor Right
* CursUp - Cursor Up
* CursDown - Cursor Down
*
* Version markers: This file is a generic macro version. The beginning
* of the lines are marked with a particular comment string
* see list below. To produce a particular version of these
* macros simply remove all markers of the particular kind
* to make the particular lines active. Otherwise the macro
* compiler will treat them as a comment only. Warning: Be
* careful not to destroy this generic version while making
* a particular version (Use menu command Save as... and NOT
* Save!).
* List of used markers (first '*' is omitted to allow for global remove, so
* that the list below is not destroyed while producing
* a particular version)
* af* - Line used in A. Fischlin's version for any Mac
* jt* - Line used in J. Thoeny's version for any Mac
* or* - Line used in O. Roth's version for any Mac SE & II sg
* tn* - Line used in T. Nemecek's version for any Mac II sg
* XX* - Line used in version for: student, staff & faculty of ETHZ
* mini* - Line used in version for Mini RAMSES Shell
* legend: sg = swiss german keyboard, us = us ascii keyboard
**********************************************************************************
*
* Globally used string resources ('STR '):
* ID 0-4
*
* Globally used string variables:
*
* $9 : path to folder containing "ErrList.DOK" (relative to MacMETH folder)
* $8 : name of the M2-shell
* $7 : last name of user
* $6 : first name of user
* $5 : pattern expression for finding M2-error mark
* $4 :
* Locally used:
* $3 : div.
* $2 : procedure name
* $1 : div.
* $0 : module name
*
* Locally used numeric variables:
* #0, #1, #2, #6-#9
* --------------------------------------------------------------------------------
* 01
* Find all compiled M2 files and open the erroneous/first in list
* NOTE: this is the autoexec macro!
!"Open work file[s]/0" • {
* at least one window must be open for autoexec macro
* New; IF Window(1) { Window(0); Close };
Set( $7, GetStr(0) );
IF Len($7) = 0 {
* adapt here for your configuration:
* *********************************
*jt* Set($8," MacMETH"); Set($9,":M2Tools:"); Set($7,"Thoeny"); Set($6,"Juerg");
*or* Set($8," MacMETH"); Set($9,":M2Tools:"); Set($7,"Roth"); Set($6,"Olivier");
*af* Set($8," RMSMacMETH"); Set($9,":M2Tools:"); Set($7,"Fischlin"); Set($6,"Andreas");
*tn* Set($8," MacMETH"); Set($9,":M2Tools:"); Set($7,"Nemecek"); Set($6,"Thomas");
Set($8," MacMETH"); Set($9,":M2Tools:"); Set($7,"(*.Your last name.*)"); Set($6,"(*.Your first name.*)");
* *********************************
Call(09); }
ELSE {
Set( $6, GetStr(1) );
Set( $8, GetStr(2) );
Set( $9, GetStr(3) );
};
Set($5,"†[ 0-9][ 0-9][0-9]†");
IF NOT Open( "err.DAT") {
Alert( Concat( "Can't find and open the Modula-2 compilation error file: '", "err.DAT", "'" ) );
Alert( "Move MEdit and/or compile your Modula-2 source file(s)" ); }
ELSE {
Set(#0,0);
Select(0,0);
Set(#1,AbsPos);
WHILE Find("¿") {
Set(#2, AbsPos-#1 ); Set(#2, #2 MOD 7 );
IF #2 = 0 {
* i.e. filename mark found
* NOTE: ".*[ ]" contains 0C in brackets!
EFind(".*[ ]");
Select(L.,C.|L.,C:-1);
Set($1,$S);
Select(L.,C:+1|L.,C:+2);
Set(#1,AbsPos);
IF StrCmp($S,"¡",1) = 0 {
IF NOT Open($1) {
Alert( Concat("Can't find and open source file '", $1, "' containing Modula-2 errors!") );
Alert( "Try Macro 'Configure' and/or compile your Modula-2 source file(s)" );
SelAbs(AbsPos+1); }
ELSE {
Set(#0,#0+1);
Window(#0);
};
};
SelAbs(AbsPos-1);
};
};
IF #0 = 0 {
* no file with compilation errors, open first:
Select(0,1);
EFind(".*[ ]");
Select(L.,C.|L.,C:-1);
Set($1,$S);
IF NOT Open($1) {
Alert( Concat("Can't find and open Modula-2 file '", $1, "'") );
Alert( "Try Macro 'Configure' and/or compile your Modula-2 source file(s)" ); }
ELSE {
Set(#0,#0+1);
Window(#0);
};
};
Close;
IF #0 > 0 Call(02);
};
};
* 02
* jumps ,to the next Modula-2 error mark and displays an alert
"Find next error/E" {
IF Len($S) > 5 Select(L.,C:-5|L.,C:);
IF EFind ($5) {
Select(L.,C.|L.,C:)!;
Set($3,SubStr($S,2,3));
Set(#8,Val($3));
IF #8 = 263 {
Select(L.,C<|L.,C:);
Select(L.,C.-1|L.,C:);
Select(L.,C<|L.,C:);
Select(L.,C>|L.,C:);
Select(L.,C.-1|L.,C:);
Set(#7,Ord(SubStr($S,1,1)));
IF #7 = Ord("=") {
Select(L.,C.-1|L.,C:);
Select(L.,C<|L.,C:);
} ELSE {
IF NOT #7 = Ord(",") AND NOT #7 = Ord(" ") {
Select(L.,C.+1|L.,C:);
};
};
IF Len($S) < 5{
Select(L.,C:-5|L.,C:);
Select(L.,C<|L.,C:);
};
Beep;
};
Set(#7,0); Set(#8,0); Set(#9,0);
WHILE #8 = 0 AND #7 = 0 {
IF Window(#9) {
IF StrCmp(WName,"ErrList.DOK",0) = 0 Set(#8,1);
}
ELSE
Set(#7,1);
Set(#9,#9+1);
};
IF #8 = 0 {
IF Open( Concat($9,"ErrList.DOK") ) {
PlaceW( ScrH-50, 2, ScrH-2, 500 );
Set(#8,1);
}
ELSE
Alert( Concat("Can't find and open compilation error message file '",$9,"ErrList.DOK'"));
};
IF #8 = 1 {
Select(VAL($3)-40,0);
Set( $1, Concat( "^- ", $3, " .*" ) );
EFind( $1 )!;
IF NOT Val($3) = 263 {
EAlert( "Modula-2 Error:", SubStr($S,8,255) );
};
Window(#7);
};
}
ELSE {
Beep;
Select(L.,C.|L:,C:)!;
}
};
* 03
* Clear error marks, close and Launch Modula-2 shell
"Clear, save & launch/1" {
Call(07);
* Compile/simulate message 'COMP' ≈ 17231 = C + O = 43H = 4FH; 19792 = M + P = 4DH + 50H
IF POSTHL("RAMS","DMEv",17231, 19792, 0) ELSE IF POSTHL("ETHM","DMEv",17231, 19792, 0);
* IF POSTHL("RAMS","MnCh",129,5,0) ELSE IF POSTHL("ETHM","MnCh",129,5,0);
Launch( GetStr(2) );
};
* --------------------------------------------------------------------------------
* 04
* insert a line in the menu
"-" {};
* 05
* Launch Modula-2 shell and Simulate
"Launch shell & simulate/2" •{
* Compile/simulate message 'COMP' ≈ 17231 = C + O = 43H = 4FH; 19792 = M + P = 4DH + 50H
IF POSTHL("RAMS","DMEv",17231, 19792, 0) ELSE IF POSTHL("ETHM","DMEv",17231, 19792, 0);
Launch( GetStr(2) );
};
* 06
* Launch Modula-2 shell
"Launch shell/3" •{
Launch( GetStr(2) );
};
* 07
* Close Modula-2-source file
"Clear error marks & save/8" {
Select(0,0);
WHILE EFind ($5) Clear;
Save;
Select(0,0);
Close;
};
* 08
* Remove Modula-2-error marks
* alternate (invisible) errmark: EFIND(" ")
"Clear error marks/9" {
Sect(0);
Select(0,0);
WHILE EFind ($5) Clear;
};
* 09
"Configure" •{
Set( $4, GetStr(0) );
IF NOT Len($4) = 0 Set($7,$4);
IF Prompt( "Your last name:", $7 ) {
IF NOT Len($4) = 0 Set( $6, GetStr(1) );
IF Prompt( "Your first name:", $6 ) {
IF NOT Len($4) = 0 Set( $9, GetStr(3) );
IF Prompt( "Relative path to 'ErrList.DOK':", $9 ) {
IF NOT Len($4) = 0 Set( $8, GetStr(2) );
IF Prompt( "Name of the Modula-2 shell (e.g. MacMETH):", $8 ) {
PutStr( 0, $7 );
PutStr( 1, $6 );
PutStr( 2, $8 );
PutStr( 3, $9 );
}
}
}
}
};
* --------------------------------------------------------------------------------
* 10
* insert a line in the menu
"-" {};
* 11
* Insert a DEFINITION MODULE template (Option^M)
"MODULE DEF Opt M" 346 •{
IF Prompt("Enter DEF Module name ",$0) {
New;
Push;
Insert("DEFINITION MODULE ");
Insert($0);
Insert(";\N");
Insert("\N");
Insert(" (*******************************************************************\N");
Insert("\N");
Insert(" Module "); Insert($0); Insert(" (Version 1.0)\N");
Insert("\N");
Insert(Concat(" Copyright (c) 19",SubStr(Date(2),7,2)," by ",$6," ",$7," and Swiss\N"));
Insert(" Federal Institute of Technology Zürich ETHZ\N");
Insert("\N");
Insert(" Purpose (*. purpose .*)\N");
Insert(" \N");
Insert(" Remarks (*. remarks. .*)\N");
Insert(" \N");
Insert(" Programming\N");
Insert("\N");
*af* Insert(" o Design and Implementation\N");
*jt* Insert(" o Design\N");
*or* Insert(" o Design and Implementation\N");
*tn* Insert(" o Design\N");
Insert(" o Design\N");
Set($3,Concat(" ",SubStr($6,0,1),". ",$7," ",Date(2),"\N\N"));
Insert($3);
*jt* Insert(" o Implementation\N"); Insert($3);
*tn* Insert(" o Implementation\N"); Insert($3);
Insert(" o Implementation\N"); Insert($3);
Insert(" \N");
Insert(" Swiss Federal Institute of Technology Zurich ETHZ\N");
*af* Insert(" Systems Ecology - Institute of Terrestrial Ecology\N");
*jt* Insert(" Systems Ecology\N");
*or* Insert(" Systems Ecology\N");
*tn* Insert(" Systems Ecology\N");
*af* Insert(" \N");
Insert(" Systems Ecology - Institute of Terrestrial Ecology\N");
*af* Insert(" Department of Environmental Sciences\N");
*jt* Insert(" Department of Environmental Sciences\N");
*or* Insert(" Department of Environmental Sciences\N");
*tn* Insert(" Department of Environmental Sciences\N");
*af* Insert(" Grabenstr. 3\N");
*jt* Insert(" Grabenstr. 3\N");
*or* Insert(" Grabenstr. 3\N");
*tn* Insert(" Grabenstr. 3\N");
Insert(" Grabenstr. 3\N");
Insert(" CH-8952 Schlieren/Zurich\N");
Insert(" Switzerland\N");
Insert("\N");
Insert(" Last revision of definition: ");
Insert(Concat(Date(2)," ",SubStr($6,0,1),SubStr($7,0,1),"\N"));
Insert("\N");
Insert(" *******************************************************************)\N");
Insert("\N");
Insert("\N");
Insert(" (*. .*)\N");
Insert("\N");
Insert("END ");
Insert($0);
Insert(".\N");
Call(38);
QSavAs(Concat($0,".DEF"));
};
};
* 12
* Insert an IMPLEMENTATION MODULE template
* [for DEF: Opt-M]
"MODULE MOD/M" •{
IF Prompt("Enter Module name ",$0) {
New;
Push;
Insert("(*. IMPLEMENTATION .*)MODULE "); Insert($0); Insert(";\N\N");
Call(36);
Insert("\N");
Insert("\N");
Insert("BEGIN\N");
Insert(" (*.Statement.*)\N");
Insert("END ");
Insert($0);
Insert(".\N");
Call(38);
QSavAs(Concat($0,".MOD"));
};
};
* 13
* Derive an empty implementation module from a correct definition module
* NOTE: this version does NOT function CORRECTLY FOR:
* - syntactically incorrect DEF modules, e.g: unbalanced brackets, etc!
* ==> compile DEF module before running that macro
* - DEF modules containing more than 1 section (default = 32K)
* ==> remove some lengthy comments
* - if some keywords (i.e: PROCEDURE, END) appear in comments or types.
* ==> correct manually (anyway: the compiler will notice these errors).
"Module DEF->MOD" {
* first copy all to a new window:
Select( 0,0 );
IF NOT Find( "DEFINITION" ) {
Alert( "Not as a definition module recognized!" ); }
ELSE {
Select( 0,0 | L$,C$ );
Copy;
New;
Paste;
* substitute DEFINITION by IMPLEMENTATION:
Select( 0,0 );
Push;
Find( "DEFINITION" );
Clear;
Insert( "IMPLEMENTATION" );
Find( " MODULE " );
Select( L.,C: );
EFind( "[A-Za-z][A-Za-z0-9]*" );
Set( $0, $S );
* replace header comment (these string are written by macro "MODULE DEF"):
Select( L.+1,0 );
IF Find("(**************************************************") {
Select( L.,0 );
Push;
Select( L.,C$-3 );
IF NOT Find("***************************************************)")
Find("*)");
Select(L[,C[ | L:,C:)!;
Drop;
Clear;
};
Call(36);
* leave imports as they are:
WHILE Find ("IMPORT " ) {
Find( ";" );
IF C. = C$ Select( L.+1,0 )
ELSE Select( L. ,C.+1 );
};
* clear heading const, type, var declarations:
* note: const, type or var later inbetween procs are not filtered!
Push;
IF Find( "PROCEDURE " ) {
Select(L[,C[|L.-1,C$);
Clear;
Insert( "\N\N" ); };
Drop;
* do procedures:
Select( L.,C.| L$,C$ );
Call(15);
* make body:
Select( L$-10,0 );
WHILE Find( "END " ) {};
Select( L.,0 );
IF Find("END ") {
Select( L.,0 );
Insert( "\N" );
Insert( "BEGIN\N ");
Insert( " (*.Statement.*)\N" ); }
ELSE
Alert( "Bad syntax, no 'END' of module encountered!" );
};
Call(38);
QSavAs( Concat($0,".MOD") );
};
* 14
* insert a PROCEDURE template (Option^P)
"PROCEDURE Opt P" 335 {
Push;
IF Prompt("Enter Procedure name",$2) {
Insert("PROCEDURE "); Insert($2);
*af* Insert(";(*. VAR .*)\n");
*jt* Insert(";(*. VAR .*)\n");
*or* Insert("( (*. VAR .*) );(*. .*)\n");
*tn* Insert(";(*. .*)\n");
Insert("( (*. VAR .*) );(*. .*)\n");
* Insert(" CONST (*.Constants.*);\n");
* Insert("TYPE (*.Types.*);\n");
* Insert(" VAR (*.Variables.*);\n");
* Insert("\b\bBEGIN\n (*.Statement.*)\n\b\bEND ");
Insert("BEGIN\n (*.Statement.*)\n\b\bEND ");
Insert($2);
Insert(";(*. continue... .*)");
Call(38);
};
};
* 15
* expand the header of a "DEF" procedure to an empty implementation
* assumes that the headers of procs to be expanded are selected before call
* (supports recursive comments in argument list)
* NOTE: that procedure will NOT function CORRECTLY if the brackets of
* comments or argument list are not balanced!
"Proc[s] DEF->MOD" {
Set( #1, L$ );
Select( L.,C. );
Push;
WHILE Find( "PROCEDURE " ) AND L. < #1 {
Select( L.,C: );
EFind( "[A-Za-z][A-Za-z0-9]*" );
Set( $3, $S );
Set( #0, -1 );
IF EFind( "[;(]" ) {
IF Ord($S) = Ord(";")
Set( #0, 0 )
ELSE {
Set( #0, 1 );
WHILE #0 > 0 {
IF EFind( "[()]" ) {
IF Ord($S) = Ord("(") Set( #0, #0+1 )
ELSE Set( #0, #0-1 ); }
ELSE
Set( #0, -1 );
};
IF #0 < 0 OR NOT Find( ";" ) Set( #0, -1 );
};
IF #0 = 0 {
Select( L.+1, 0 );
Push;
Find( "(*" );
IF L. = L[ {
IF Find( "*)" ) {
Select( L[,C[ | L.,C: );
Clear;
Drop; }
ELSE
Pop;
}
ELSE
Pop;
Insert( " (*. VAR .*)\N" );
Insert( " BEGIN\N" );
Insert( " (*.Statement.*)\N" );
Insert( " END " ); Insert( $3 ); Insert( ";\N\N" );
* we have to add the number of inserted lines to update orig. selection
Set (#1, #1+5); }
}
ELSE
Alert( "Bad syntax, no ';' found!" );
};
Call(38);
};
* 16
* insert a FOR-TO-DO template (Option^F)
"FOR Opt F" 303 {
Push;
Insert("FOR (*.loop var.*):= (*.expr.*) TO (*.expr.*) DO\n");
Insert(" (*.Statement.*)\n");
Insert("\b\bEND(*FOR*);(*. continue... .*)");
Call(38);
};
* 17
* insert a CASE template (Option^S)
"CASE Opt S" 301 {
Push;
Insert("CASE (*.expr.*) OF\n");
Insert(" (*.Constant.*) : (*.Statement.*)\n");
Insert("\b\b| (*.Constant.*) : (*.Statement.*)\n");
* Insert("\b\bELSE\N (*.Statement.*);\n");
Insert("END(*CASE*);(*. continue... .*)");
Call(38);
};
* 18
* insert an IF-THEN-ELSE template (Option^I)
* af version: Option^J is similar to Option^I
* Using I may cause problems since I is diacritical with US-ASCII
* keyboard, i.e. the first character z typed will eventually carry
* a "^" if z may be used for a diacritical construction; otherwise
* z will be preceeded by a "^". In any case the user must first
* delete these characters before he may (re)start with actual typing.
* Remark: Option^J has nothing to do with macro Command J (Jump to line
* with a particular #)
*af*"IF THEN Opt J" 338
*jt*"IF THEN Opt J" 338
*or*"IF THEN Opt I" 334
*tn*"IF THEN Opt I" 334
"IF THEN Opt J" 338
{ Push;
Insert("IF (*.Condition.*) THEN\n (*.Statement.*)\n");
Insert("\b\bELSE\n (*.Statement.*)\n");
Insert("\b\bEND(*IF*);(*. continue... .*)");
Call(38);
};
* 19
* Insert a WHILE-DO-END template (Option^W)
"WHILE Opt W" 313 {
Push;
Insert("WHILE (*.Condition.*) DO\n");
Insert(" (*.Statement.*)\n");
Insert("\b\bEND(*WHILE*);(*. continue... .*)");
Call(38);
};
* 20
* Insert a REPEAT-UNTIL template (Option^R)
"REPEAT Opt R" 315 {
Push;
Insert("REPEAT\n");
Insert(" (*.Statement.*)\n");
Insert("\b\bUNTIL (*. Condition .*);(*. continue... .*)");
Call(38);
};
* 21
* Insert a WITH-DO-END template (Option^H)
"WITH Opt H" 304 {
Push;
Insert("WITH (*.Designator.*) DO\n");
Insert(" (*.Statement.*)\n");
Insert("\b\bEND(*WITH*);(*. continue... .*)");
Call(38);
};
* --------------------------------------------------------------------------------
* 22
* insert a line in the menu
"-" {};
* 23
* puts comment-braces (like placeholders) around the current selection
"Comment/K" {
Push;
Select(L],C]);
Insert(" .*)");
Select(L[,C[);
Insert("(*. ");
Pop;
IF L. = L: Select(L.,C. | L:,C:+8)
ELSE Select(L.,C. | L:,C:+5);
};
* 24
* removes comment-braces at start and end of the current selection
* af version: (Option^K)
*af*"Uncomment Opt K" 340
*jt*"Uncomment Opt K" 340
*or*"Uncomment/U" 340
*tn*"Uncomment/U" 340
"Uncomment Opt K" 340
{
Push;
Select(L],C]-4 | L],C]);
Clear;
Select(L[,C[ | L[,C[+4);
Clear;
Pop;
};
* 25
* Move all lines in the current selection to the right by inserting
* a double space. do nothing for empty lines.
"Move sel. right/R" {
Push;
WHILE L. < L] {
Select(L.,0);
IF NOT C$ = 0 Insert(" ");
Select(L.+1,0)!;
};
Select(L[,0|L],0);
Drop;
};
* 26
* Move all lines in the current selection one position to the left
* by deleting the leftmost characters. do nothing for empty lines.
"Move sel. left/L" {
Push;
WHILE L. < L] {
Select(L.,0|L.,1);
Clear;
Select(L.+1,0)!;
};
Select(L[,0|L],0);
Drop;
};
* 27
* Replace all 'real' tabs by blank strings
* this is useful to convert 'Edit'- to 'MEdit'-files
"Replace tabs" {
SECT(0);
Select(0,0);
WHILE FIND("\9") Insert("\t");
BEEP;
};
* 28
* rearrange comments by wrapping the end of
* too long lines to the next line or filling lines too short lines
* The comment must already contain comment braces such as "(*" and "*)"
* and the Auto indent on resp. Line wrap around mode off!!!!!
"Wrap comments/A" {
* save current selection and assign last line of selection to #1
Push; Set(#1,L]);
* set cursor to begin of selection and search for comment begin
Select(L[,C[); FIND("(*");
* add at end of comment begin a new line in any case, update #1
Select(L.,C:); Insert("\n "); Set(#1,#1+1);
* save current selection, which is left margin of comment text
Push;
* select and clear any blanks or empty lines till begin of text
WHILE C> = -1 { Select(L.+1,C>) ; Set(#1,#1-1) };
Select(L.,C>);
Select(L[,C[ | L:,C<); Clear; Drop;
* WHILE comment:
WHILE L. < #1
{
* IF line is too long insert after last whole word an EOL (wrap
* around mode), update #1
IF C$ > 68
{
Select(L.,68); Select(L.,C<);
Insert("\n"); Set(#1,#1+1);
}
* ELSE current line is too short, hence remove EOL, update #1, and
* remove all blanks except for one till begin of next word (fill mode)
* unless it is the last line
ELSE
{
IF L. < #1-1
{
Select(L.,C$ | L.+1,0); Clear; Set(#1,#1-1);
Select(L.,C<); Select(L.,C>); Insert(" ");
Push;
Select(L.,C>); Select(L[,C[ | L.,C<); Clear; Drop;
} ELSE Set(#1,#1-1);
};
};
* Find "*)" which is on the current line (was filled in) and
* insert an EOL before it, shift it to the left by 2 columns
Select(L.,0); FIND("*)"); Select(L.,C.);
Insert("\n");
Select(L.,C.-2 | L.,C.); Clear;
* Add an EOL after comment (has been removed during fill in) and
* restore selection
Select(L.,C$); Insert("\N");
Select(L[,C[ | L.,0)!;
Drop;
};
* 29
* rearrange text by wrapping the end of
* too long lines to the next line or filling lines too short lines
* Option ^ W (works if text not commented (s.a. Macro 22)
* left margin of text is given by first word begin in selection
"Wrap text Opt A" 300 {
* save current selection and assign last line of selection to #1
Push; Set(#1,L]);
* set cursor to begin of selection
Select(L[,C[);
* WHILE text:
WHILE L. < #1
{
* IF line is too long insert after last whole word an EOL (wrap
* around mode), update #1
IF C$ > 68
{
Select(L.,68); Select(L.,C<);
Insert("\n"); Set(#1,#1+1);
}
* ELSE current line is too short, hence remove EOL, update #1, and
* remove all blanks except for one till begin of next word (fill mode)
* unless it is the last line
ELSE
{
IF L. < #1-1
{
Select(L.,C$ | L.+1,0); Clear; Set(#1,#1-1);
Select(L.,C<); Select(L.,C>); Insert(" ");
Push;
Select(L.,C>); Select(L[,C[ | L.,C<); Clear; Drop;
} ELSE Set(#1,#1-1);
};
};
* Add an EOL after text (has been removed during fill in) and
* restore selection
Select(L.,C$); Insert("\N");
Select(L[,C[ | L.,0)!;
Drop;
};
* --------------------------------------------------------------------------------
* 30
* insert a line in the menu (line separator)
"-" {};
*-*************-*
*-* Movements *-*
*-*************-*
* 31
* Bring last window to front
"Flip windows/H" {
Set(#0,0); WHILE Window(#0) Set(#0,#0+1); Window(#0-1);
};
* 32
* Ask for a line number to jump to and do it
"Jump to Line/J" {
Prompt("Goto Line",#6);
Select(#6-1,C. | #6-1,C.)!;
};
* 33
* jumps to the next placeholder in a Modula-2 structure
* Alternative keyboard entry: Option^G ~ 305
*af*"Placeholder Opt G/G" 305
*jt*"Placeholder Opt G/G" 305
*or*"Placeholder Opt -" 344
*tn*"Placeholder Opt -" 344
"Placeholder Opt G/G" 305
{
Find("(*.");
IF L: = 0 AND C: = 0 Find("(*.");
Push;
Find(".*)");
Select(L[,C[ | L:,C:)!;
Drop;
};
* 34
* For use together with the following macros
"Save position/B" {
Push;
};
* 35
* Jumps back to the last position saved with macro 2 (Option^B)
* the stack can hold the last eight positions
"Back to position Opt B" 311 {
Select(L[,C[)!;
Pop;
};
*==================================================================*
* !!! From here on depending on the version macros with or without *
* menu entries. NOTE: macros with menu entries will function only *
* properly if they are defined in a sequence from the beginning *
* without ANY! macro stuck in between WITHOUT menu entry !!! *
*==================================================================*
* ………
*============================================================*
* !!! Add from here on only(!) macros with NO menu entry !!! *
*============================================================*
* 36
* insert implementation header info:
{
Insert(" (*\N");
Insert(" Implementation and Revisions:\N");
Insert(" ============================\N");
Insert("\N");
Insert(" Author Date Description\N");
Insert(" ------ ---- -----------\N");
Insert("\N");
Insert(Concat(" ",SubStr($6,0,1),SubStr($7,0,1)," ",Date(2)));
Insert(" First implementation\N");
Insert("\N");
Insert(" *)\N");
Insert("\N");
Insert("\N");
Insert(" (*.imports.*)\N");
};
* 37
* delete to end of line option - BS ~ 351
351 {
Select(L.,C.|L.,C$);
Clear;
};
* 38
* select first placeholder
* !!!! this macro is called by many other macros !!!!
{
Pop;
Find("(*.");
Push;
Find(".*)");
Select(L[,C[ | L:,C:)!;
Drop;
};
* 39
* select current word (like double click)
*: <Enter>
(1,76)
{
Select(L.,C< | L.,C>)!;
}.
* --------------------------------------------------------------------------------
*** only a maximum of 60 macros are supported by the MComp = V1.40 ***